<?php
//执行异步写文件

$content = "hello world";
$filename = "test.txt";

swoole_async_writefile($filename, $content, function ($filename) {
    echo "文件 $filename 写入成功\n";
    echo "文件内容为：{$content}\n";
    echo "文件长度为：".filesize($filename)."\n";
    echo "文件权限为：".substr(sprintf('%o', fileperms($filename)), -4)."\n";
    echo "文件大小为：".filesize($filename)."\n";
}